package com.example.reactor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

public class ReactorClient {

    private static final Logger log = LoggerFactory.getLogger(ReactorClient.class);

    public static void main(String[] args) throws IOException {
        log.info("hello world");
        SocketChannel client = SocketChannel.open();
        client.connect(new InetSocketAddress(8080));
        //ByteBuffer buffer = Charset.defaultCharset().encode("青春");
        // buffer.put("cool".getBytes(StandardCharsets.UTF_8));
        ByteBuffer buffer = StandardCharsets.UTF_8.encode("青春");
        client.write(buffer);
        log.info("发送消息成功");
        client.close();
    }
}
